AUTO_FILES("." "src" "\\.(cpp|h)$")
if(MSVC_VERSION LESS 1600)
  AUTO_FILES("${ROOT_SOURCE_DIR}/dep/src/capstone/msvc" "src" "\\.h$")
endif()
AUTO_FILES("${ROOT_SOURCE_DIR}/dep/src/capstone-3.0.5/include" "src" "\\.h$")
AUTO_FILES("${ROOT_SOURCE_DIR}/dep/src/capstone-3.0.5" "src" "capstone-3.0.5/[^/]+\\.(c|h)$")
AUTO_FILES("${ROOT_SOURCE_DIR}/dep/src/capstone-3.0.5/arch/ARM" "src" "\\.(c|h|inc)$")
include_directories(${DEP_INCLUDE_DIR} "${ROOT_SOURCE_DIR}/dep/src/capstone-3.0.5/include")
if(MSVC_VERSION LESS 1600)
  include_directories("${ROOT_SOURCE_DIR}/dep/src/capstone/msvc")
endif()
link_directories(${DEP_LIBRARY_DIR})
add_definitions(-DSDW_MAIN -DCURL_STATICLIB -DCAPSTONE_USE_SYS_DYN_MEM -DCAPSTONE_HAS_ARM)
if(APPLE)
  add_definitions(-DSDW_XCONVERT)
endif()
ADD_EXE(3dstool "${src}")
if(WIN32)
  if(MSVC)
    if(MSVC_VERSION LESS 1800)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4005")
    endif()
    target_link_libraries(3dstool libcurl libcrypto WS2_32 Wldap32 Crypt32)
    set(3dstool_LINK_FLAGS_DEBUG "${3dstool_LINK_FLAGS_DEBUG} /NODEFAULTLIB:LIBCMT")
    if(MSVC_VERSION GREATER 1700)
      set(3dstool_LINK_FLAGS_DEBUG "${3dstool_LINK_FLAGS_DEBUG} /IGNORE:4099")
      set(3dstool_LINK_FLAGS_RELWITHDEBINFO "${3dstool_LINK_FLAGS_RELWITHDEBINFO} /IGNORE:4099")
    endif()
    set_target_properties(3dstool PROPERTIES
      LINK_FLAGS_DEBUG "${3dstool_LINK_FLAGS_DEBUG}"
      LINK_FLAGS_RELWITHDEBINFO "${3dstool_LINK_FLAGS_RELWITHDEBINFO}")
  else()
    target_link_libraries(3dstool curl crypto)
  endif()
else()
  target_link_libraries(3dstool curl ssl crypto)
  if(APPLE)
    target_link_libraries(3dstool ldap)
  else()
    target_link_libraries(3dstool pthread dl)
  endif()
  if(APPLE OR CYGWIN)
    target_link_libraries(3dstool iconv)
  endif()
endif()
install(TARGETS 3dstool DESTINATION bin)
